<template>
  <div class="display">
    <div class="display-header">
      <div class="left">
        <span class="datetime">{{ curDate }} 星期{{ curDay }}</span>
      </div>
      <div class="title">
        <h1>大屏展示Demo</h1>
      </div>
      <div class="right">
        <span class="datetime">{{ curTime }}</span>
      </div>
    </div>
    <div class="display-body">
      <div class="display-body-left">
        <div class="display-item" />
        <div class="display-item" />
        <div class="display-item" />
      </div>

      <div class="display-body-right">
        <div class="display-item" />
        <div class="display-item" />
        <div class="display-item" />
      </div>
    </div>
  </div>
</template>

<script>
import { dateFormatter } from '@/utils/utils'

export default {
  name: 'Index',
  data() {
    return {
      curDate: '',
      curDay: '',
      curTime: ''
    }
  },
  created() {
    this.getCurTime()
    setInterval(() => {
      this.getCurTime()
    })

    const today = new Date()
    this.curDate = dateFormatter(today, false)
    this.curDate = this.curDate.split('-').join('.')
    this.curDay = '日一二三四五六'.charAt(today.getDay())
  },
  methods: {
    getCurTime() {
      const d = new Date()
      const hour = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
      const minute = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
      const second = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
      this.curTime = hour + ' : ' + minute + ' : ' + second
    }
  }
}
</script>

<style lang="scss">
.display {
  width: 100vw;
  height: 100vh;
  background: url("~@/assets/bg.png");
  background-size: 100%;
  .display-header {
    width: 100%;
    height: 74px;
    color: #FFFFFF;
    display: flex;
    justify-content: center;
    .left, .right {
      width: 568px;
      height: 100%;
      position: relative;
      .datetime {
        color: #08D1EA;
        font-size: 16px;
        position: absolute;
        bottom: 10px;
      }
    }
    .left {
      background: url("~@/assets/header.png") no-repeat 0 0;
      background-size: cover;
      .datetime {
        right: 0;
      }
    }
    .title {
      width: 524px;
      height: 100%;
      background: url("~@/assets/header.png") no-repeat -564px 0;
      background-size: cover;
      display: flex;
      align-items: center;
      justify-content: center;
      h1 {
        font-size: 36px;
      }
    }
    .right {
      background: url("~@/assets/header.png") no-repeat -1098px 0;
      background-size: cover;
      .datetime {
        left: 0;
      }
    }
  }
  .display-body {
    width: 100%;
    height: calc(100% - 74px);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    .display-body-left, .display-body-right {
      width: 420px;
      height: 100%;
      display: grid;
      grid-template-rows: repeat(3, 1fr);
      grid-gap: 20px;
      .display-item {
        width: 100%;
        border: 30px solid;
        border-image-source: url("~@/assets/border.png");
        border-image-slice: 30;
      }
    }
  }
}
</style>
